home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / CDTools / S / search.rexx < prev    next >
OS/2 REXX Batch file  |  2000-12-02  |  3KB  |  120 lines

  1. /*
  2.     Searches the CD index files
  3.     $VER: Search.rexx 1.1 (8.11.2000)
  4.     (c) Neil Bothwick, Wirenet
  5.  
  6.     1.1  - Uses "parse source" to get the name of the CD
  7. */
  8.  
  9. /* ;;; Initialise */
  10. options results
  11. signal on error
  12. parse source . ' ' . ' ' . ' ' ScriptName ' ' .
  13. CDName = left(ScriptName, pos(':', ScriptName) - 1)
  14.  
  15. call LoadLib('rexxsupport.library')
  16. call LoadLib('rexxdossupport.library')
  17. call LoadLib('rexxreqtools.library')
  18.  
  19. parse arg args
  20. args = compress(args,'a0'x)
  21. do until args = ''
  22.     parse var args a '"' b '"' args
  23.     interpret a||'"'||b||'"'
  24.     args = strip(args,'L')
  25.     end
  26.  
  27. if SearchStr = '' then call ExitMsg('You must give a string to search for')
  28. 'urlencode "'SearchStr'" var SearchEnc'
  29. OutputURL = 'x-aweb:searchresults/'SearchEnc
  30. OutputFile = 'T:CDsearch.results'
  31. AWebPort = address()
  32. if left(AWebPort,5) ~= 'AWEB.' then call ExitMsg('This script can only be run*Nfrom a link inside AWeb')
  33. ;;;
  34. /* ;;; Search */
  35. Search:
  36.     call delete(OutputFile)
  37.     select
  38.         when Source = 'Amigactive' then do
  39.             signal off error
  40.             address command 'FlashFind 'CDName':CDTools/indices/'CDName' "'SearchStr'" NH >'OutputFile
  41.             if RC = 5 then Matches = 0
  42.             signal on error
  43.             nop
  44.             end
  45.         when Source = 'Aminet CDs' then do
  46.             nop
  47.             end
  48.         when Source = 'Aminet' then do
  49.             nop
  50.             end
  51.         otherwise nop
  52.         end
  53. /* Show matches or warn if none */
  54. /*
  55. if word(statef(OutFile),2) = 0 then call ReqMsg('No matches found for "'SearchStr'"')
  56. else address command 'Multiview' OutFile
  57. 'gauge id PROGR attrs' MUIA_Gauge_Current 0 MUIA_Gauge_InfoText '""'
  58. return
  59. */
  60. ;;;
  61. /* ;;; Output results */
  62. 'chanopen'  OutputURL
  63. ChanID = result
  64. 'chanheader' ChanID '"Content-Type: text/html"'
  65. 'chanheader' ChanID '"Pragma: No-cache"'
  66. 'chandata' ChanID '"<html><head><title>Search results</title></head><body bgcolor=white>"'
  67. 'chandata' ChanID '"<h3 align=center>Searching for "<font color=red>'SearchStr'</font>" in 'Source'</h2>" newline'
  68. 'open'  OutputURL
  69. 'chandata' ChanID '"<a href=*"file://localhost/'CDName':html/SearchCD.html*">Another search</a><p>" newline'
  70. 'chandata' ChanID '"<table width=*"100%*">" newline'
  71.  
  72. call open(res,OutputFile,'R')
  73. do until eof(res)
  74.     line = readln(res)
  75.     if line = '' then iterate
  76.     parse var line name 34 path
  77.     name = strip(name,'T')
  78.     'chandata' ChanID '"<tr><td><a href=*"x-aweb:rexx/REXX:AAShowDir 'PathPart(path)'*">'name'</a><td>'path'" newline'
  79.     end
  80. 'chandata' ChanID '"</table>" newline'
  81. 'chandata' ChanID '"<p><a href=*"file://localhost/'CDName':html/SearchCD.html*">Another search</a>" newline'
  82. 'chandata' ChanID '"</body></html>" newline'
  83. 'chanclose' ChanID
  84. call close(res)
  85. 'open'  OutputURL
  86. ;;;
  87. /* ;;; Cleanup and exit */
  88. CleanUp:
  89.     call delete(OutputFile)
  90.     call close(res)
  91.     exit
  92. ;;;
  93. /* ;;; Exit with a message */
  94. ExitMsg:
  95.     parse arg msg
  96.     call ShowMsg(msg)
  97.     call CleanUp()
  98.     return
  99. ;;;
  100. /* ;;; Error handler */
  101. Error:
  102.     call ExitMsg('Error' RC 'in line' sigl)
  103.     return
  104. ;;;
  105. /* ;;; Show a message in a requester */
  106. ShowMsg:
  107.     parse arg msg
  108.     'request "Amigactive CD" "'msg'" "OK" nowait'
  109.     return
  110. ;;;
  111. /* ;;; Load library */
  112. LoadLib:
  113.     parse arg library
  114.     if show('L',library) then return
  115.     if ~exists('LIBS:'library) then address command 'copy 'CDName':System/libs/'library 'LIBS: clone quiet'
  116.     if ~addlib(library,0,-30,0) then call ExitMsg('Failed to load' library||'0a'x||'Make sure you have run InitCD')
  117.     return
  118. ;;;
  119.  
  120.